package com.example.messagemodule.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.example.messagemodule.R;

@SuppressLint("AppCompatCustomView")
public class MessageBackgroundRight extends LinearLayout {
    public MessageBackgroundRight(Context context) {
        super(context);
    }

    public MessageBackgroundRight(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MessageBackgroundRight(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(getResources().getColor(R.color.new_theme));
        paint.setStrokeWidth(5);
        paint.setStyle(Paint.Style.FILL);

        int width = getWidth();
        int height = getHeight();

        Path path = new Path();
        path.moveTo(0, 20);
        path.lineTo(0, height-20);
        path.quadTo(0, height-20, 20, height);
        path.lineTo(width-35, height);
        path.quadTo(width-35, height, width-15, height-20);
        path.lineTo(width-15, 70);
        path.lineTo(width-0, 60);
        path.lineTo(width-15, 50);
        path.lineTo(width-15, 20);
        path.quadTo(width-15, 20, width-35, 0);
        path.lineTo(20, 0);
        path.quadTo(20, 0, 0, 20);
        //X、Y坐标，radius半径
        canvas.drawCircle(20, 20, 20, paint);
        canvas.drawCircle(width-35, 20, 20, paint);
        canvas.drawCircle(20, height-20, 20, paint);
        canvas.drawCircle(width-35, height-20, 20, paint);
        path.close();
        canvas.drawPath(path, paint);
    }
}
